package com.redpack.quick.controller;

import com.redpack.quick.common.beans.Result;
import com.redpack.quick.consts.Constants;
import com.redpack.quick.datasource.entity.CompanyEntity;
import com.redpack.quick.datasource.entity.TaskEntity;
import com.redpack.quick.service.ICompany;
import com.redpack.quick.service.ITask;
import com.redpack.quick.utils.ExceptionUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * Created by shuttle on 5/25/17.
 */
@RestController
@RequestMapping(Constants.BASE_URL + "/task")
@Api(description = "logo相关")
public class TaskController extends BaseController  {

    @Autowired
    private ITask task;

    @ApiOperation(value = "获取task列表", notes = "获取task列表", response = Result.class)
    @RequestMapping(value = "/getTasks", method = { RequestMethod.POST}, produces = "application/json;charset=utf-8")
    public Result<Page<TaskEntity>> getTasks(@RequestParam("pageSize") int pageSize,
                                              @RequestParam("pageNum") int pageNum){
        return successResult(task.findByPage(pageSize, pageNum));
    }

    @ApiOperation(value = "通过id获取任务", notes = "通过id获取任务", response = Result.class)
    @RequestMapping(value = "/getTaskById", method = { RequestMethod.POST}, produces = "application/json;charset=utf-8")
    public Result<TaskEntity> getTaskById(@RequestParam("id") long id){
        return successResult(task.findById(id));
    }

    @ApiOperation(value = "获取帮助信息的文字", notes = "获取帮助信息的文字", response = Result.class)
    @RequestMapping(value = "/getHelpTxt", method = { RequestMethod.POST}, produces = "application/json;charset=utf-8")
    public Result<String> getHelpMessage(){
        return successResult("帮助文档内容");
    }
}
